<?php

// No direct access.
	defined('_JEXEC') or die;

// check modules
	$showRightColumn = $this->countModules('rightcontent');
	$showSubMenu = $this->countModules('submenu');

	JHtml::_('behavior.framework', true);

// get params
	$logo = ($this->params->get('logo') != null) ? $this->params->get('logo') : $this->baseurl . '/templates/' . $this->template . '/images/bg-header.jpg';
	$app = JFactory::getApplication();
	$doc = JFactory::getDocument();
	$templateparams = $app->getTemplate(true)->params;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:jdoc="http://www.w3.org/1999/XSL/Transform"
      xml:lang="<?php echo $this->language; ?>"
      lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
    <jdoc:include type="head" />
    <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css" type="text/css"/>
    <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/common.css"
          type="text/css"/>
</head>

<body>
<?php
$runningTaxEnabled = ($this->params->get('runningTaxEnabled') != null) ? $this->params->get('runningTaxEnabled') : 0;

if ($runningTaxEnabled > 0) {
    $year = ($this->params->get('year') != null) ? $this->params->get('year') : 2013;
    $totalTax = ($this->params->get('totalTax') != null) ? $this->params->get('totalTax') : 20087000000;
    echo $totalTax;
    JFactory::getDocument()->addScriptDeclaration('
        updateCount('.$year.', '.$totalTax.', ' . ((date("z", mktime(0,0,0,12,31,$year)) + 1) * 24 * 60 * 60 * 1000) . ',"' . JText::_('TPL_POS_RUNNING_TAX') . '");

        var timeout = 20; // refresh timeout in miliseconds

        function updateCount(year, totalTax, totalMilisecondsInYear, runningTaxText) {
            var msecs = new Date() - new Date("1/1/" + year + " 0:00 AM");
            if (document.getElementById("runningTax")) {
                var s = Math.round(totalTax * msecs / totalMilisecondsInYear) + "";
                var str = s.split("").reverse().join("").replace(/(...)/g, "$1 ").split("").reverse().join("");
                document.getElementById("runningTax").innerHTML = runningTaxText.replace("XX", str) + year;
            }
            setTimeout("updateCount(" + year + "," + totalTax + "," + totalMilisecondsInYear + ",\"" + runningTaxText +  "\")", timeout);
        }
        ');
}
?>
<div id="page-wrapper">
    <div id="page">
        <div id="header">
		<!-- <map name="flagmap">
			<area href="/" coords="0,0,850,107"></area>
		</map> -->
            <img border=0 src="<?php echo $logo;?>" usemap="#flagmap"/>
        </div>
        <div id="mainmenu">
            <jdoc:include type="modules" name="mainmenu" />
            <?php if ($runningTaxEnabled > 0) { ?>
                <div style="position: relative;"><span style="color: #ca3601; position: absolute; right: 5px; padding-top: 7px" id="runningTax" title="<?php echo 'main_menu_tooltip_cntelem'; ?>">0</span></div>
            <?php } ?>
        </div>
        <div id="middle">
			<?php if ($showRightColumn) : ?><div id="main-column"><?php endif; ?>
            <div id="main-tables-wrapper">
                <jdoc:include type="modules" name="maincontent" />
                <jdoc:include type="message" />
                <jdoc:include type="component" />
            </div>
            <div id="footmenu">
                <jdoc:include type="modules" name="footmenu" />
                <div class="cb">&nbsp;</div>
            </div>
			<?php if ($showRightColumn) : ?></div><?php endif; ?>
			<?php if ($showRightColumn) : ?>
            <div id="right-column">
                <jdoc:include type="modules" name="rightcontent" />
            </div>
			<?php endif; ?>
            <div class="cb">&nbsp;</div>
        </div>
    </div>
</div>
</body>
<jdoc:include type="modules" name="debug" />
</body>
</html>
